
export default {
    namespaced: true,
    state: {
        productData:[]
    },
    getters: {
        
    },
    mutations: {
        ADD(state,payload){
            state.productData = payload
            
        },
        PRODUCT_REMOVE(state,payload){
            let target = state.productData.find(item=>item.id===payload.id)
            if (target) {
            target.inventory++

            }
        }
    },
    actions: {
       async FETCH(context,payload){
           let res =await fetch('http://chst.vip/data/index.json')
           .then(body=>body.json())
          context.commit('ADD',res.data)
        }
    }
}